package com.ymatou.iapi.godfreightmgr.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.godfreightmgr.parameter.GetFreightPolicyModeBean;
import com.ymatou.iapi.godfreightmgr.service.GetFreightPolicyModeCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.database.model.seller_freight_config;
import com.ymttest.database.sqlwapper.godfreight.seller_freight_configWapper;
import com.ymttest.utils.AgentUsers;
/**
*查询组合运费策略
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetFreightPolicyMode{
	private static GetFreightPolicyModeBean getfreightpolicymodeBean;
	private static GetFreightPolicyModeCall getfreightpolicymodeCall;
	private static int sellerId = AgentUsers.rootUserId;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("查询组合运费策略");
	}

	@Before
	public void caseUp() {
		getfreightpolicymodeBean=new GetFreightPolicyModeBean();
		getfreightpolicymodeCall=new GetFreightPolicyModeCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getfreightpolicymodeCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetFreightPolicyMode_01() {
		Logger.start(true,"查询组合运费策略，成功");
		try {
			getfreightpolicymodeBean.setSellerId(sellerId);
			getfreightpolicymodeCall.setData(getfreightpolicymodeBean);
			getfreightpolicymodeCall.callService();			
			Logger.verifyEquals("200",getfreightpolicymodeCall.getString("code"),"验证code");
			int policyModel = getfreightpolicymodeCall.getJsonObject().get("data").getAsJsonObject().get("policyModel").getAsInt();
			seller_freight_configWapper freightConfigWapper = new seller_freight_configWapper();
			seller_freight_config config = freightConfigWapper.selectByPrimaryKey(sellerId);
			Logger.verifyEquals(policyModel,config.getFreightCalcMode(),"验证policyModel");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetFreightPolicyMode_02() {
		Logger.start(true,"sellerId为空，失败");
		try {
			getfreightpolicymodeCall.setData(getfreightpolicymodeBean);
			getfreightpolicymodeCall.callService();
			Logger.verifyEquals("400",getfreightpolicymodeCall.getString("code"),"验证code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}